home *** CD-ROM | disk | FTP | other *** search
/ CD Concept 6 / CD Concept 06.iso / mac / UTILITAIRE / RLaB / rlib / mean.r < prev    next >
Text File  |  1994-09-23  |  524b  |  25 lines

  1. //-------------------------------------------------------------------//
  2. //
  3. //  Syntax:    mean ( A )
  4.  
  5. //  Description:
  6.  
  7. //  Calculate the mean value. If the input is a 1xN, then compute the
  8. //  mean value of all the elements. 
  9.  
  10. //  If the input is a MxN matrix the compute a row matrix of the mean
  11. //  value of each column of the input. 
  12. //
  13. //-------------------------------------------------------------------//
  14.  
  15. mean = function(x)
  16. {
  17.   m = size (x)[1];
  18.   if( m == 1 ) 
  19.   { 
  20.     m = size (x)[2];
  21.   }
  22.  
  23.   return sum( x ) / m;
  24. };
  25.